﻿package fl.controls
{
    import fl.controls.listClasses.*;
    import fl.core.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import flash.ui.*;
    import flash.utils.*;

    public class TileList extends SelectableList implements IFocusManagerComponent
    {
        protected var _rowHeight:Number = 50;
        protected var _columnWidth:Number = 50;
        protected var _scrollDirection:String = "horizontal";
        protected var _scrollPolicy:String = "auto";
        protected var _cellRenderer:Object;
        protected var oldLength:uint = 0;
        protected var _labelField:String = "label";
        protected var _labelFunction:Function;
        protected var _iconField:String = "icon";
        protected var _iconFunction:Function;
        protected var _sourceField:String = "source";
        protected var _sourceFunction:Function;
        protected var __rowCount:uint = 0;
        protected var __columnCount:uint = 0;
        private var collectionItemImport:TileListCollectionItem;
        private static var defaultStyles:Object = {cellRenderer:ImageCell, focusRectSkin:null, focusRectPadding:null, skin:"TileList_skin"};
        public static var createAccessibilityImplementation:Function;

        public function TileList()
        {
            return;
        }// end function

        override public function get dataProvider() : DataProvider
        {
            return super.dataProvider;
        }// end function

        override public function set dataProvider(param1:DataProvider) : void
        {
            super.dataProvider = param1;
            return;
        }// end function

        public function get labelField() : String
        {
            return this._labelField;
        }// end function

        public function set labelField(param1:String) : void
        {
            if (param1 == this._labelField)
            {
                return;
            }
            this._labelField = param1;
            invalidate(InvalidationType.DATA);
            return;
        }// end function

        public function get labelFunction() : Function
        {
            return this._labelFunction;
        }// end function

        public function set labelFunction(param1:Function) : void
        {
            if (this._labelFunction == param1)
            {
                return;
            }
            this._labelFunction = param1;
            invalidate(InvalidationType.DATA);
            return;
        }// end function

        public function get iconField() : String
        {
            return this._iconField;
        }// end function

        public function set iconField(param1:String) : void
        {
            if (param1 == this._iconField)
            {
                return;
            }
            this._iconField = param1;
            invalidate(InvalidationType.DATA);
            return;
        }// end function

        public function get iconFunction() : Function
        {
            return this._iconFunction;
        }// end function

        public function set iconFunction(param1:Function) : void
        {
            if (this._iconFunction == param1)
            {
                return;
            }
            this._iconFunction = param1;
            invalidate(InvalidationType.DATA);
            return;
        }// end function

        public function get sourceField() : String
        {
            return this._sourceField;
        }// end function

        public function set sourceField(param1:String) : void
        {
            this._sourceField = param1;
            invalidate(InvalidationType.DATA);
            return;
        }// end function

        public function get sourceFunction() : Function
        {
            return this._sourceFunction;
        }// end function

        public function set sourceFunction(param1:Function) : void
        {
            this._sourceFunction = param1;
            invalidate(InvalidationType.DATA);
            return;
        }// end function

        override public function get rowCount() : uint
        {
            var _loc_1:* = Number(getStyleValue("contentPadding"));
            var _loc_2:* = Math.max(1, (_width - 2 * _loc_1) / this._columnWidth << 0);
            var _loc_3:* = Math.max(1, (_height - 2 * _loc_1) / this._rowHeight << 0);
            if (this._scrollDirection == ScrollBarDirection.HORIZONTAL)
            {
                if (this._scrollPolicy == ScrollPolicy.ON || this._scrollPolicy == ScrollPolicy.AUTO && length > _loc_2 * _loc_3)
                {
                    _loc_3 = Math.max(1, (_height - 2 * _loc_1 - 15) / this._rowHeight << 0);
                }
            }
            else
            {
                _loc_3 = Math.max(1, Math.ceil((_height - 2 * _loc_1) / this._rowHeight));
            }
            return _loc_3;
        }// end function

        public function set rowCount(param1:uint) : void
        {
            if (param1 == 0)
            {
                return;
            }
            if (componentInspectorSetting)
            {
                this.__rowCount = param1;
                return;
            }
            this.__rowCount = 0;
            var _loc_2:* = Number(getStyleValue("contentPadding"));
            var _loc_3:* = Math.ceil(length / param1) > width / this.columnWidth >> 0 && this._scrollPolicy == ScrollPolicy.AUTO || this._scrollPolicy == ScrollPolicy.ON;
            height = this.rowHeight * param1 + 2 * _loc_2 + (this._scrollDirection == ScrollBarDirection.HORIZONTAL && _loc_3 ? (ScrollBar.WIDTH) : (0));
            return;
        }// end function

        public function get rowHeight() : Number
        {
            return this._rowHeight;
        }// end function

        public function set rowHeight(param1:Number) : void
        {
            if (this._rowHeight == param1)
            {
                return;
            }
            this._rowHeight = param1;
            invalidate(InvalidationType.SIZE);
            return;
        }// end function

        public function get columnCount() : uint
        {
            var _loc_1:* = Number(getStyleValue("contentPadding"));
            var _loc_2:* = Math.max(1, (_width - 2 * _loc_1) / this._columnWidth << 0);
            var _loc_3:* = Math.max(1, (_height - 2 * _loc_1) / this._rowHeight << 0);
            if (this._scrollDirection != ScrollBarDirection.HORIZONTAL)
            {
                if (this._scrollPolicy == ScrollPolicy.ON || this._scrollPolicy == ScrollPolicy.AUTO && length > _loc_2 * _loc_3)
                {
                    _loc_2 = Math.max(1, (_width - 2 * _loc_1 - 15) / this._columnWidth << 0);
                }
            }
            else
            {
                _loc_2 = Math.max(1, Math.ceil((_width - 2 * _loc_1) / this._columnWidth));
            }
            return _loc_2;
        }// end function

        public function set columnCount(param1:uint) : void
        {
            if (param1 == 0)
            {
                return;
            }
            if (componentInspectorSetting)
            {
                this.__columnCount = param1;
                return;
            }
            this.__columnCount = 0;
            var _loc_2:* = Number(getStyleValue("contentPadding"));
            var _loc_3:* = Math.ceil(length / param1) > height / this.rowHeight >> 0 && this._scrollPolicy == ScrollPolicy.AUTO || this._scrollPolicy == ScrollPolicy.ON;
            width = this.columnWidth * param1 + 2 * _loc_2 + (this._scrollDirection == ScrollBarDirection.VERTICAL && _loc_3 ? (15) : (0));
            return;
        }// end function

        public function get columnWidth() : Number
        {
            return this._columnWidth;
        }// end function

        public function set columnWidth(param1:Number) : void
        {
            if (this._columnWidth == param1)
            {
                return;
            }
            this._columnWidth = param1;
            invalidate(InvalidationType.SIZE);
            return;
        }// end function

        public function get innerWidth() : Number
        {
            drawNow();
            var _loc_1:* = getStyleValue("contentPadding") as Number;
            return width - _loc_1 * 2 - (_verticalScrollBar.visible ? (_verticalScrollBar.width) : (0));
        }// end function

        public function get innerHeight() : Number
        {
            drawNow();
            var _loc_1:* = getStyleValue("contentPadding") as Number;
            return height - _loc_1 * 2 - (_horizontalScrollBar.visible ? (_horizontalScrollBar.height) : (0));
        }// end function

        public function get direction() : String
        {
            return this._scrollDirection;
        }// end function

        public function set direction(param1:String) : void
        {
            if (this._scrollDirection == param1)
            {
                return;
            }
            this._scrollDirection = param1;
            invalidate(InvalidationType.SIZE);
            return;
        }// end function

        public function get scrollPolicy() : String
        {
            return this._scrollPolicy;
        }// end function

        public function set scrollPolicy(param1:String) : void
        {
            if (!componentInspectorSetting && this._scrollPolicy == param1)
            {
                return;
            }
            this._scrollPolicy = param1;
            if (this.direction == ScrollBarDirection.HORIZONTAL)
            {
                _horizontalScrollPolicy = param1;
                _verticalScrollPolicy = ScrollPolicy.OFF;
            }
            else
            {
                _verticalScrollPolicy = param1;
                _horizontalScrollPolicy = ScrollPolicy.OFF;
            }
            invalidate(InvalidationType.SIZE);
            return;
        }// end function

        override public function scrollToIndex(param1:int) : void
        {
            var _loc_3:Number = NaN;
            var _loc_4:Number = NaN;
            drawNow();
            var _loc_2:* = Math.max(1, contentWidth / this._columnWidth << 0);
            if (this._scrollDirection == ScrollBarDirection.VERTICAL)
            {
                if (this.rowHeight > availableHeight)
                {
                    return;
                }
                _loc_3 = (param1 / _loc_2 >> 0) * this.rowHeight;
                if (_loc_3 < verticalScrollPosition)
                {
                    verticalScrollPosition = _loc_3;
                }
                else if (_loc_3 > verticalScrollPosition + availableHeight - this.rowHeight)
                {
                    verticalScrollPosition = _loc_3 + this.rowHeight - availableHeight;
                }
            }
            else
            {
                if (this.columnWidth > availableWidth)
                {
                    return;
                }
                _loc_4 = param1 % _loc_2 * this.columnWidth;
                if (_loc_4 < horizontalScrollPosition)
                {
                    horizontalScrollPosition = _loc_4;
                }
                else if (_loc_4 > horizontalScrollPosition + availableWidth - this.columnWidth)
                {
                    horizontalScrollPosition = _loc_4 + this.columnWidth - availableWidth;
                }
            }
            return;
        }// end function

        override public function itemToLabel(param1:Object) : String
        {
            if (this._labelFunction != null)
            {
                return String(this._labelFunction(param1));
            }
            if (param1[this._labelField] == null)
            {
                return "";
            }
            return String(param1[this._labelField]);
        }// end function

        override public function get verticalScrollPolicy() : String
        {
            return null;
        }// end function

        override public function set verticalScrollPolicy(param1:String) : void
        {
            return;
        }// end function

        override public function get horizontalScrollPolicy() : String
        {
            return null;
        }// end function

        override public function set horizontalScrollPolicy(param1:String) : void
        {
            return;
        }// end function

        override public function get maxHorizontalScrollPosition() : Number
        {
            drawNow();
            return _maxHorizontalScrollPosition;
        }// end function

        override public function set maxHorizontalScrollPosition(param1:Number) : void
        {
            return;
        }// end function

        override protected function configUI() : void
        {
            super.configUI();
            _horizontalScrollPolicy = this.scrollPolicy;
            _verticalScrollPolicy = ScrollPolicy.OFF;
            return;
        }// end function

        override protected function setHorizontalScrollPosition(param1:Number, param2:Boolean = false) : void
        {
            invalidate(InvalidationType.SCROLL);
            super.setHorizontalScrollPosition(param1, true);
            return;
        }// end function

        override protected function setVerticalScrollPosition(param1:Number, param2:Boolean = false) : void
        {
            invalidate(InvalidationType.SCROLL);
            super.setVerticalScrollPosition(param1, true);
            return;
        }// end function

        override protected function draw() : void
        {
            if (this.direction == ScrollBarDirection.VERTICAL)
            {
                if (this.__rowCount > 0)
                {
                    this.rowCount = this.__rowCount;
                }
                if (this.__columnCount > 0)
                {
                    this.columnCount = this.__columnCount;
                }
            }
            else
            {
                if (this.__columnCount > 0)
                {
                    this.columnCount = this.__columnCount;
                }
                if (this.__rowCount > 0)
                {
                    this.rowCount = this.__rowCount;
                }
            }
            var _loc_1:* = this.oldLength != length;
            this.oldLength = length;
            if (isInvalid(InvalidationType.STYLES))
            {
                setStyles();
                drawBackground();
                if (contentPadding != getStyleValue("contentPadding"))
                {
                    invalidate(InvalidationType.SIZE, false);
                }
                if (this._cellRenderer != getStyleValue("cellRenderer"))
                {
                    _invalidateList();
                    this._cellRenderer = getStyleValue("cellRenderer");
                }
            }
            if (isInvalid(InvalidationType.SIZE, InvalidationType.STATE) || _loc_1)
            {
                this.drawLayout();
            }
            if (isInvalid(InvalidationType.RENDERER_STYLES))
            {
                updateRendererStyles();
            }
            if (isInvalid(InvalidationType.STYLES, InvalidationType.SIZE, InvalidationType.DATA, InvalidationType.SCROLL, InvalidationType.SELECTED))
            {
                this.drawList();
                _maxHorizontalScrollPosition = Math.max(0, contentWidth - availableWidth);
            }
            updateChildren();
            validate();
            return;
        }// end function

        override protected function drawLayout() : void
        {
            var _loc_1:uint = 0;
            var _loc_2:uint = 0;
            _horizontalScrollPolicy = this._scrollDirection == ScrollBarDirection.HORIZONTAL ? (this._scrollPolicy) : (ScrollPolicy.OFF);
            _verticalScrollPolicy = this._scrollDirection != ScrollBarDirection.HORIZONTAL ? (this._scrollPolicy) : (ScrollPolicy.OFF);
            if (this._scrollDirection == ScrollBarDirection.HORIZONTAL)
            {
                _loc_1 = this.rowCount;
                contentHeight = _loc_1 * this._rowHeight;
                contentWidth = this._columnWidth * Math.ceil(length / _loc_1);
            }
            else
            {
                _loc_2 = this.columnCount;
                contentWidth = _loc_2 * this._columnWidth;
                contentHeight = this._rowHeight * Math.ceil(length / _loc_2);
            }
            super.drawLayout();
            return;
        }// end function

        override protected function drawList() : void
        {
            var _loc_1:uint = 0;
            var _loc_2:uint = 0;
            var _loc_3:Object = null;
            var _loc_4:ICellRenderer = null;
            var _loc_11:uint = 0;
            var _loc_12:uint = 0;
            var _loc_15:Dictionary = null;
            var _loc_16:uint = 0;
            var _loc_17:uint = 0;
            var _loc_18:uint = 0;
            var _loc_19:uint = 0;
            var _loc_20:Boolean = false;
            var _loc_21:String = null;
            var _loc_22:Object = null;
            var _loc_23:Object = null;
            var _loc_24:Sprite = null;
            var _loc_25:String = null;
            var _loc_26:UIComponent = null;
            var _loc_5:* = this.rowCount;
            var _loc_6:* = this.columnCount;
            var _loc_7:* = this.columnWidth;
            var _loc_8:* = this.rowHeight;
            var _loc_9:Number = 0;
            var _loc_10:Number = 0;
            var _loc_27:* = contentPadding;
            listHolder.y = contentPadding;
            listHolder.x = _loc_27;
            contentScrollRect = listHolder.scrollRect;
            contentScrollRect.x = Math.floor(_horizontalScrollPosition) % _loc_7;
            contentScrollRect.y = Math.floor(_verticalScrollPosition) % _loc_8;
            listHolder.scrollRect = contentScrollRect;
            listHolder.cacheAsBitmap = useBitmapScrolling;
            var _loc_13:Array = [];
            if (this._scrollDirection == ScrollBarDirection.HORIZONTAL)
            {
                _loc_16 = availableWidth / _loc_7 << 0;
                _loc_17 = Math.max(_loc_16, Math.ceil(length / _loc_5));
                _loc_9 = _horizontalScrollPosition / _loc_7 << 0;
                _loc_6 = Math.max(_loc_16, Math.min(_loc_17 - _loc_9, (_loc_6 + 1)));
                _loc_12 = 0;
                while (_loc_12 < _loc_5)
                {
                    
                    _loc_11 = 0;
                    while (_loc_11 < _loc_6)
                    {
                        
                        _loc_2 = _loc_12 * _loc_17 + _loc_9 + _loc_11;
                        if (_loc_2 >= length)
                        {
                            break;
                        }
                        _loc_13.push(_loc_2);
                        _loc_11 = _loc_11 + 1;
                    }
                    _loc_12 = _loc_12 + 1;
                }
            }
            else
            {
                _loc_5 = _loc_5 + 1;
                _loc_10 = _verticalScrollPosition / _loc_8 << 0;
                _loc_18 = Math.floor(_loc_10 * _loc_6);
                _loc_19 = Math.min(length, _loc_18 + _loc_5 * _loc_6);
                _loc_1 = _loc_18;
                while (_loc_1 < _loc_19)
                {
                    
                    _loc_13.push(_loc_1);
                    _loc_1 = _loc_1 + 1;
                }
            }
            var _loc_27:* = new Dictionary(true);
            renderedItems = new Dictionary(true);
            var _loc_14:* = _loc_27;
            for each (_loc_2 in _loc_13)
            {
                
                _loc_14[_dataProvider.getItemAt(_loc_2)] = true;
            }
            _loc_15 = new Dictionary(true);
            while (activeCellRenderers.length > 0)
            {
                
                _loc_4 = activeCellRenderers.pop();
                _loc_3 = _loc_4.data;
                if (_loc_14[_loc_3] == null || invalidItems[_loc_3] == true)
                {
                    availableCellRenderers.push(_loc_4);
                }
                else
                {
                    _loc_15[_loc_3] = _loc_4;
                    invalidItems[_loc_3] = true;
                }
                list.removeChild(_loc_4 as DisplayObject);
            }
            invalidItems = new Dictionary(true);
            _loc_1 = 0;
            for each (_loc_2 in _loc_13)
            {
                
                _loc_11 = _loc_1 % _loc_6;
                _loc_12 = _loc_1 / _loc_6 << 0;
                _loc_20 = false;
                _loc_3 = _dataProvider.getItemAt(_loc_2);
                if (_loc_15[_loc_3] != null)
                {
                    _loc_20 = true;
                    _loc_4 = _loc_15[_loc_3];
                    delete _loc_15[_loc_3];
                }
                else if (availableCellRenderers.length > 0)
                {
                    _loc_4 = availableCellRenderers.pop() as ICellRenderer;
                }
                else
                {
                    _loc_4 = getDisplayObjectInstance(getStyleValue("cellRenderer")) as ICellRenderer;
                    _loc_24 = _loc_4 as Sprite;
                    if (_loc_24 != null)
                    {
                        _loc_24.addEventListener(MouseEvent.CLICK, handleCellRendererClick, false, 0, true);
                        _loc_24.addEventListener(MouseEvent.ROLL_OVER, handleCellRendererMouseEvent, false, 0, true);
                        _loc_24.addEventListener(MouseEvent.ROLL_OUT, handleCellRendererMouseEvent, false, 0, true);
                        _loc_24.addEventListener(Event.CHANGE, handleCellRendererChange, false, 0, true);
                        _loc_24.doubleClickEnabled = true;
                        _loc_24.addEventListener(MouseEvent.DOUBLE_CLICK, handleCellRendererDoubleClick, false, 0, true);
                        if (_loc_24["setStyle"] != null)
                        {
                            for (_loc_25 in rendererStyles)
                            {
                                
                                var _loc_31:* = _loc_24;
                                _loc_31._loc_24["setStyle"](_loc_25, rendererStyles[_loc_25]);
                            }
                        }
                    }
                }
                list.addChild(_loc_4 as Sprite);
                activeCellRenderers.push(_loc_4);
                _loc_4.y = _loc_8 * _loc_12;
                _loc_4.x = _loc_7 * _loc_11;
                _loc_4.setSize(this.columnWidth, this.rowHeight);
                _loc_21 = this.itemToLabel(_loc_3);
                _loc_22 = null;
                if (this._iconFunction != null)
                {
                    _loc_22 = this._iconFunction(_loc_3);
                }
                else if (this._iconField != null)
                {
                    _loc_22 = _loc_3[this._iconField];
                }
                _loc_23 = null;
                if (this._sourceFunction != null)
                {
                    _loc_23 = this._sourceFunction(_loc_3);
                }
                else if (this._sourceField != null)
                {
                    _loc_23 = _loc_3[this._sourceField];
                }
                if (!_loc_20)
                {
                    _loc_4.data = _loc_3;
                }
                _loc_4.listData = new TileListData(_loc_21, _loc_22, _loc_23, this, _loc_2, _loc_10 + _loc_12, _loc_9 + _loc_11) as ListData;
                _loc_4.selected = _selectedIndices.indexOf(_loc_2) != -1;
                if (_loc_4 is UIComponent)
                {
                    _loc_26 = _loc_4 as UIComponent;
                    _loc_26.drawNow();
                }
                _loc_1 = _loc_1 + 1;
            }
            return;
        }// end function

        override protected function keyDownHandler(event:KeyboardEvent) : void
        {
            var _loc_2:int = 0;
            event.stopPropagation();
            if (!selectable)
            {
                return;
            }
            switch(event.keyCode)
            {
                case Keyboard.UP:
                case Keyboard.DOWN:
                {
                    this.moveSelectionVertically(event.keyCode, event.shiftKey && _allowMultipleSelection, event.ctrlKey && _allowMultipleSelection);
                    break;
                }
                case Keyboard.PAGE_UP:
                case Keyboard.PAGE_DOWN:
                case Keyboard.END:
                case Keyboard.HOME:
                {
                    if (this._scrollDirection == ScrollBarDirection.HORIZONTAL)
                    {
                        this.moveSelectionHorizontally(event.keyCode, event.shiftKey && _allowMultipleSelection, event.ctrlKey && _allowMultipleSelection);
                    }
                    else
                    {
                        this.moveSelectionVertically(event.keyCode, event.shiftKey && _allowMultipleSelection, event.ctrlKey && _allowMultipleSelection);
                    }
                    break;
                }
                case Keyboard.LEFT:
                case Keyboard.RIGHT:
                {
                    this.moveSelectionHorizontally(event.keyCode, event.shiftKey && _allowMultipleSelection, event.ctrlKey && _allowMultipleSelection);
                    break;
                }
                default:
                {
                    _loc_2 = getNextIndexAtLetter(String.fromCharCode(event.keyCode), selectedIndex);
                    if (_loc_2 > -1)
                    {
                        selectedIndex = _loc_2;
                        scrollToSelected();
                    }
                    break;
                    break;
                }
            }
            return;
        }// end function

        protected function calculateAvailableHeight() : Number
        {
            var _loc_1:* = Number(getStyleValue("contentPadding"));
            return height - _loc_1 * 2 - (_horizontalScrollPolicy == ScrollPolicy.ON || _horizontalScrollPolicy == ScrollPolicy.AUTO && _maxHorizontalScrollPosition > 0 ? (15) : (0));
        }// end function

        override protected function moveSelectionVertically(param1:uint, param2:Boolean, param3:Boolean) : void
        {
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_4:* = Math.max(1, Math.max(contentHeight, availableHeight) / this._rowHeight << 0);
            var _loc_5:* = Math.ceil(Math.max(this.columnCount * this.rowCount, length) / _loc_4);
            var _loc_6:* = Math.ceil(length / _loc_5);
            switch(param1)
            {
                case Keyboard.UP:
                {
                    _loc_7 = selectedIndex - _loc_5;
                    break;
                }
                case Keyboard.DOWN:
                {
                    _loc_7 = selectedIndex + _loc_5;
                    break;
                }
                case Keyboard.HOME:
                {
                    _loc_7 = 0;
                    break;
                }
                case Keyboard.END:
                {
                    _loc_7 = length - 1;
                    break;
                }
                case Keyboard.PAGE_DOWN:
                {
                    _loc_8 = selectedIndex + _loc_5 * (_loc_6 - 1);
                    if (_loc_8 >= length)
                    {
                        _loc_8 = _loc_8 - _loc_5;
                    }
                    _loc_7 = Math.min((length - 1), _loc_8);
                    break;
                }
                case Keyboard.PAGE_UP:
                {
                    _loc_8 = selectedIndex - _loc_5 * (_loc_6 - 1);
                    if (_loc_8 < 0)
                    {
                        _loc_8 = _loc_8 + _loc_5;
                    }
                    _loc_7 = Math.max(0, _loc_8);
                    break;
                }
                default:
                {
                    break;
                }
            }
            this.doKeySelection(_loc_7, param2, param3);
            scrollToSelected();
            return;
        }// end function

        override protected function moveSelectionHorizontally(param1:uint, param2:Boolean, param3:Boolean) : void
        {
            var _loc_4:uint = 0;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            _loc_4 = Math.ceil(Math.max(this.rowCount * this.columnCount, length) / this.rowCount);
            switch(param1)
            {
                case Keyboard.LEFT:
                {
                    _loc_5 = Math.max(0, (selectedIndex - 1));
                    break;
                }
                case Keyboard.RIGHT:
                {
                    _loc_5 = Math.min((length - 1), (selectedIndex + 1));
                    break;
                }
                case Keyboard.HOME:
                {
                    _loc_5 = 0;
                    break;
                }
                case Keyboard.END:
                {
                    _loc_5 = length - 1;
                    break;
                }
                case Keyboard.PAGE_UP:
                {
                    _loc_6 = selectedIndex - selectedIndex % _loc_4;
                    _loc_5 = Math.max(0, Math.max(_loc_6, selectedIndex - this.columnCount));
                    break;
                }
                case Keyboard.PAGE_DOWN:
                {
                    _loc_7 = selectedIndex - selectedIndex % _loc_4 + _loc_4 - 1;
                    _loc_5 = Math.min((length - 1), Math.min(_loc_7, selectedIndex + _loc_4));
                    break;
                }
                default:
                {
                    break;
                }
            }
            this.doKeySelection(_loc_5, param2, param3);
            scrollToSelected();
            return;
        }// end function

        protected function doKeySelection(param1:uint, param2:Boolean, param3:Boolean) : void
        {
            var _loc_6:uint = 0;
            var _loc_7:int = 0;
            var _loc_4:* = selectedIndices;
            var _loc_5:Boolean = false;
            if (param1 < 0 || param1 > (length - 1))
            {
            }
            else if (param2 && _loc_4.length > 0 && param1 != _loc_4[0])
            {
                _loc_6 = _loc_4[0];
                _loc_4 = [];
                if (param1 < _loc_6)
                {
                    _loc_7 = _loc_6;
                    while (_loc_7 >= param1)
                    {
                        
                        _loc_4.push(_loc_7);
                        _loc_7 = _loc_7 - 1;
                    }
                }
                else
                {
                    _loc_7 = _loc_6;
                    while (_loc_7 <= param1)
                    {
                        
                        _loc_4.push(_loc_7);
                        _loc_7++;
                    }
                }
                _loc_5 = true;
            }
            else
            {
                _loc_4 = [param1];
                caretIndex = param1;
                _loc_5 = true;
            }
            selectedIndices = _loc_4;
            if (_loc_5)
            {
                dispatchEvent(new Event(Event.CHANGE));
            }
            invalidate(InvalidationType.DATA);
            return;
        }// end function

        override protected function initializeAccessibility() : void
        {
            if (TileList.createAccessibilityImplementation != null)
            {
                TileList.createAccessibilityImplementation(this);
            }
            return;
        }// end function

        public static function getStyleDefinition() : Object
        {
            return mergeStyles(defaultStyles, SelectableList.getStyleDefinition(), ScrollBar.getStyleDefinition());
        }// end function

    }
}
